package com.test.action;

import java.util.List;

import com.opensymphony.xwork2.ActionContext;
import com.test.base.BaseAction;
import com.test.domain.Forum;

public class ForumManagerAction extends BaseAction<Forum>{
	private static final long serialVersionUID = 1L;
	public String list() throws Exception{
		//准备数据
		List<Forum> forumList = forumService.findAllForum();
		ActionContext.getContext().put("forumList", forumList);
		return "list";
	}
	public String addUI() throws Exception{
		return "saveUI";
	}
	public String add() throws Exception{
		/*Forum forum = new Forum();
		forum.setName(model.getName());
		forum.setDiscription(model.getDiscription());
		forumService.addForum(forum);*/
		forumService.addForum(model);
		return "toList";
	}
	public String editUI() throws Exception{
		//准备数据
		Forum forum = forumService.findForumById(model.getId());
		ActionContext.getContext().getValueStack().push(forum);
		return "saveUI";
	}
	public String edit() throws Exception{
		Forum forum = forumService.findForumById(model.getId());
		forum.setName(model.getName());
		forum.setDescription(model.getDescription());
		forumService.updateForum(forum);
		return "toList";
	}
	public String delete() throws Exception{
		forumService.deleteForum(model.getId());
		return "toList";
	}
	public String moveUp() throws Exception{
		forumService.moveUp(model.getId());
		return "toList";
	}
	public String moveDown() throws Exception{
		forumService.moveDown(model.getId());
		return "toList";
	}
}
